/**
 * 
 */
package com.validatecsv.csvfilereader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.csvreader.CsvReader;

/**
 * @author Shreyash
 * 
 */
public class CsvFileReaderUtility {

	public List<String[]> readCsvFileToGenerateList(String fileName) {
		CsvReader csvReader = null;
		List<String[]> fieldValueList = new ArrayList<String[]>();
		try {
			csvReader = new CsvReader(fileName);

			csvReader.readHeaders();

			while (csvReader.readRecord()) {
				String fieldValueArray[] = csvReader.getValues();

				fieldValueList.add(fieldValueArray);
			}

			csvReader.close();

		} catch (FileNotFoundException e) {
			// as of now we will use printStackTrace but we will have to use a
			// logger soon.
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		return fieldValueList;

	}

}
